<?php
/**
 * Created by PhpStorm.
 * User: Yui
 * Date: 2017/5/25 0025
 * Time: 17:25
 */

namespace common\services;


use common\payment\wxpayv3\WxPayApi;
use common\payment\wxpayv3\WxPayUnifiedOrder;

class WechatAppSve extends BaseSve
{
    /**
     * 创建支付
     * @param $outTradeNo //支付单号
     * @param $totalFee //支付金额
     * @param $subject
     * @param $body
     * @return array
     */
    public function createPay($outTradeNo, $totalFee, $subject, $body):array
    {
        $WxPayUnifiedOrder = new WxPayUnifiedOrder();
        $WxPayUnifiedOrder->SetOut_trade_no($outTradeNo);
        $WxPayUnifiedOrder->SetBody($body);
        $WxPayUnifiedOrder->SetTotal_fee($totalFee * 100);//金额转成分
        $WxPayUnifiedOrder->SetTrade_type('APP');
        $WxPayUnifiedOrder->SetNotify_url(HTTP_DOMAIN_API . '/pay/wechat-app-notify');
        $sign = WxPayApi::unifiedOrder($WxPayUnifiedOrder);
        return self::result('支付参数创建成功', 0, ['payArr' => $sign]);
    }
}